package com.liao.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.liao.bean.Member;
import com.liao.bean.result.Msg;
import com.liao.bean.result.PageResult;
import com.liao.dao.CodeDao;
import com.liao.dao.MemberDao;
import com.liao.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MemberServiceImpl implements MemberService {

    @Autowired
    private MemberDao memberDao;

    @Override
    public PageResult<Member> queryMemberListByPage(Integer currentPage, Integer pageSize, String account) throws Exception {
        PageHelper.startPage(currentPage,pageSize);
        //查询所有菜单
        List<Member> memberList = memberDao.selectMemberListLikeMemberName(account);
        PageInfo<Member> pageInfo = new PageInfo<>(memberList);
        return new PageResult<>(0, Msg.MEMBER_QUERY_SUCCESS,pageInfo.getTotal(),pageInfo.getList());
    }

    @Override
    public void addMember(Member member) throws Exception {
        memberDao.addMember(member);
    }

    @Override
    public void editMember(Member member) throws Exception {
        memberDao.updateMember(member);
    }

    @Override
    public void deleteMember(String memberId) throws Exception {
        memberDao.deleteMember(memberId);
    }

}
